/*******************************************************************************
* COPYRIGHT LIPUJUN TECH CO.,LTD
********************************************************************************
* 文件名称:  mqttMsmgCmd.h
* 功能描述:
* 使用说明:  无
* 文件作者:  LIPUJUN
* 编写日期:  2018/11/28
* 修改历史:
* 修改版本  修改日期       修改人   修改内容
* ------------------------------------------------------------------------------
  01a       2018/11/28       李普军   创建
*******************************************************************************/

/******************************** 头文件保护开头 *****************************/
#ifndef __MSG_CORE_H /* 头文件保护 */
#define __MSG_CORE_H /* 头文件保护 */
#include "common.h"

#define MSG_HEADER_BUF_MAX_SIZE         256
#define MSG_HEADER_SIZE			20
#define APP_SUPPORT_MSG_VER		0x01   // > V2.3.0 else 0x00
#define APP_SUPPORT_MSG_VER_V2         0x02
#define APP_DEVICE_ID_SIZE_V2          10
#define _MSG_HEADER_			0x55AA
typedef enum {
	CMD_NULL = 0,			//没有消息类型
	CMD_REG,			//注册
	CMD_UPLOAD_FILE,	//上传文件
	CMD_UPLOAD_RET,		//上传结果
	CMD_DISK_CLEAR,		//清空硬盘
	CMD_UPGRADE_CMD,	//更新
	CMD_UPGRADE_RET,	//更新结果
	CMD_HEART_BEAT,		//心跳
        CMD_ONOFF,
	CMD_SIZE			//未定义消息
} CMD_TYPE_E;

typedef struct{
	UINT16 head;
	UINT8  ver;
	UINT8  type;
	UINT8  id[12];
	//UINT32 reserve32;
	UINT16 reserve16;
	UINT16 size;
} MSG_HEADER_T;

typedef struct {
	INT8* data;
	UINT16 len;
	UINT8 type;
	UINT8 ver;
	UINT8 assure;
} MSG_DATA_T;

typedef struct
{
    UINT32 wPt;
    UINT32 rPt;

    UINT32 rxCount;
    UINT32 txCount;

    UINT32 rxErrCount;
    UINT32 txErrCount;

    UINT32 rxEmpCount;
    UINT32 txFullCount;

    MSG_DATA_T *msgQ;

}MSG_QUEUE_BD_DESC;
INT32 mqttMsgTaskSend (void);
INT32 mqttRecvDataProc_task (void *arg);
INT32 air_msgBDInit (MSG_QUEUE_BD_DESC *pMsgDesc);
INT32 msg_init(void);
INT32 air_rcv_msg (UINT32 type, void *buf, int len);
INT32 air_send_msg(UINT32 type,void *buf, UINT32 len, UINT8 assure);
INT32 msgBdInit (MSG_QUEUE_BD_DESC *pMsgDesc);
void msgBdDestroy (MSG_QUEUE_BD_DESC *pMsgDesc);
INT32 msgBdRead (MSG_QUEUE_BD_DESC *pMsgDesc, MSG_DATA_T *data);
INT32 msgBdWrite (UINT32 type, MSG_QUEUE_BD_DESC *pMsgDesc, CHAR *buf, UINT32 len,UINT8 assure);
void msgBdClean(void);
BOOL msgBdRecvUniq(UINT8 type);

/******************************** 头文件保护结尾 *****************************/
#endif /* __MSG_CORE_H *//* 头文件保护 */
/******************************** 头文件结束 *********************************/
